/* Geometry Pixel Shader */

// Material Info
cbuffer MaterialBuffer : register(b0)
{
	float3	Color;
	float	Roughness;
	float4	Ambient;
	float	Specular;
	uint	UseTexture;
	float2	Padding;
};

// Pixel Input
struct PixelInput
{
	float4 Position			: SV_POSITION;
	float4 WorldPosition	: WORLDPOSITION;
	float3 Normal			: NORMAL;
	float2 TexCoord			: TEXCOORD;
};

// Pixel Output
struct PixelOutput
{
	float4 Position		: SV_TARGET0;
	float4 Normal		: SV_TARGET1;
	float4 Albedo		: SV_TARGET2;
	float4 Ambient		: SV_TARGET3;
};

Texture2D<float4>		g_DiffuseTexture	: register(t0);
SamplerState			g_TextureSampler	: register(s0);

PixelOutput main(PixelInput input)
{
	PixelOutput output = (PixelOutput)0;

	output.Position = input.WorldPosition;
	output.Normal = float4(normalize(input.Normal),Roughness);
	float3 diffuse = Color;
	if (UseTexture > 0)
		diffuse = g_DiffuseTexture.Sample(g_TextureSampler, input.TexCoord).xyz;
	output.Albedo = float4(diffuse, Specular);
	output.Ambient = Ambient;

	return output;
}